<?php
if (isset($_POST['BnfDocType'])) {
    $DetailObj[1]['BnfDocType'] = $_POST['BnfDocType'];
}
if (isset($_POST['BnfPais'])) {
    $DetailObj[1]['BnfPais'] = $_POST['BnfPais'];
}
echo '<script charset="utf-8" type="text/javascript">';
include($GLOBALS['BIB'] . 'ValScripts/doc_' . $_POST['BnfDocType'] . '.mex');
echo '</script>';

mn_field('hidden', 'ED', 'ctrl', '', '', '', '', '');
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>';
$RCDocTypes = "SELECT tdc_Id AS ID, tdc_Tipo AS NAME FROM hd_documentostipos WHERE Country_ID = {$DetailObj[1]['BnfPais']} AND tdc_Activo = 1";
mn_field('select', 'ED', 'BnfDocType', $DetailObj[1]['BnfDocType'], $RCDocTypes, '', 'False', '"
		onchange="document.ReceiverProperties.action=\'_response/call.php?get=Operative/view/viewreceiverdocument\';
		subform(\'ReceiverProperties\',\'DocVal\');');
if ($DetailObj[1]['BnfDocType'] == 7 || $DetailObj[1]['BnfDocType'] == '' || $DetailObj[1]['BnfDocType'] == 0) {
    echo '</td><td width="100%">';
    mn_field('text', 'ED', 'BnfCedula', $DetailObj[1]['BnfCedula'], '14', '13', 'True', '"
			onKeyUp="if(ValDoc(document.ReceiverProperties.BnfCedula.value)==false) {
				document.ReceiverProperties.PRSVRC.disabled=true;
				document.getElementById(\'RCDC_Msg\').innerHTML=\'<div class="Error">' . $lang['basic']['invalid'] . '</div>\';
				} else {
				document.ReceiverProperties.PRSVRC.disabled=false;
                                document.getElementById(\'RCDC_Msg\').innerHTML=\'<div class="Error">' . $lang['basic']['valid'] . '</div>\';
				setTimeout(fJS_Formata(ReceiverProperties,this.name,11,8,5,0,2,event),1000);
				}');
} elseif ($DetailObj[1]['BnfDocType'] == 8) {
    echo '</td><td width="100%">';
    mn_field('text', 'ED', 'BnfCedula', $DetailObj[1]['BnfCedula'], '18', '17', 'True', '"
			onKeyUp="if(document.ReceiverProperties.BnfCedula.value.length>=14 && document.ReceiverProperties.ctrl.value == \'\') {
			document.ReceiverProperties.ctrl.value=1;
			if(ValCNPJ(document.ReceiverProperties.BnfCedula.value)==true) {
				document.ReceiverProperties.PRSVRC.disabled=false;
                                document.getElementById(\'RCDC_Msg\').innerHTML=\'<div class="Error">' . $lang['basic']['valid'] . '</div>\';
				setTimeout(fJS_Formata(ReceiverProperties,this.name,14,12,9,6,2,event),1000);
			} else {
				document.ReceiverProperties.PRSVRC.disabled=true;
                                document.getElementById(\'RCDC_Msg\').innerHTML=\'<div class="Error">' . $lang['basic']['invalid'] . '</div>\';
			}
			} else {
				document.ReceiverProperties.PRSVRC.disabled=true;
				document.ReceiverProperties.ctrl.value=\'\';
                                document.getElementById(\'RCDC_Msg\').innerHTML=\'<div class="Error">' . $lang['basic']['invalid'] . '</div>\';
			}');
}
echo '</td>
    <td><div id="RCDC_Msg"></div></td>
  </tr>
</table>';